<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<!-- 响应式 meta标签 -->
   		<meta charset="utf-8">
    	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

		<!-- Bootstrap CSS -->
		<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
		<link rel="stylesheet" href="css/hongbao.css">
		<title>饿了么红包,饿了么一键大红包,外卖红包,拼手气红包</title>
		<meta name="keywords" content="饿了么红包,饿了么一键大红包,外卖优惠券,外卖红包,外卖满减,订餐优惠,外卖优惠,elemehb.com">
		<meta name="description" content="饿了么一键大红包专注提供饿了么拼手气红包免费领取服务,免费领取饿了么拼手气大红包,外卖订餐更优惠,免费饿了么外卖红包,地址:elemehb.com">
	</head>
	<!-- 背景图片 -->
	<body style="background-image:url(images/background.jpg);">	
		<div id="preloadedImages" style="background-image:url(images/daydayHongbao.jpg);"></div>  <!-- 预加载天天领红包图片 -->
		<div class=".container-fluid" align="center">
			<h1 style="margin-top:3%;color:#463f39;font-size:45px;font-family:Sans-serif" >饿了么一键红包</h1>
			<div class="highlight border border-secondary" style="margin-top:3%;">
				<div align="left" style="margin:0px 0px 0px 10px;">
					<h5 align="center">公告</h5>
					<hr style="margin:0px 0px 0px 0px;">
					<a id="advertising"></a>
				</div>
			</div>
			<div class="highlight border border-secondary" style="padding:1rem;">
				<form  id="formHongbao">
					<div class="input-group mb-3" >
		 				<div class="input-group-prepend" >
		    				<span class="input-group-text" id="basic-addon1">&nbsp;&nbsp;手机&nbsp;&nbsp;</span>
		  				</div>
		 				<input oninput="checkForm()" type="text" class="form-control" placeholder="输入需要领红包的手机号"  name="phoneNum" id="phone">
					</div>
					<div class="input-group mb-3" style="height:160px">
						<div class="input-group-prepend">
							<span class="input-group-text">&nbsp;&nbsp;链接&nbsp;&nbsp;</span>
						</div>
						<textarea oninput="checkForm(),urlExpand()" class="form-control " placeholder="输入红包链接" name="url" id="url"></textarea>		
					</div>
					<div align="left" >
						<div class="btn-group " role="group" aria-label="Basic example">
							<a tabindex="0" class="btn btn btn-danger " data-placement="top" role="button" data-toggle="popover" data-trigger="focus" data-html="true" title="请注意" 
							data-content="1.请不要用要领取的手机号打开红包。
							<br><br>2.饿了么红包链接开头为：https://h5.ele.me/hongbao/ 
							<br><br>3.链接不带 lucky_number 的不是拼手气红包，不能使用领取功能。
							<br><br>4.还剩一个就是大红包的情况请不要用网站领取。">注意事项
							</a>
							<!-- <button type="button" class="btn btn-secondary float-right" onclick="submitAlt()">贡献小号</button>  -->
						</div>	
						<input disabled="true" type="button"  class="btn btn-secondary float-right" value="领取红包" onclick="getHongbao()" id="get"/>
					</div>	
				</form>	
			</div>
			<!-- 统计栏 -->
			<div class="highlight border border-secondary" style="padding:1rem;">
				<div align="left">
					<ul class="nav nav-tabs" id="myTab" role="tablist">
						<li class="nav-item">
							<a class="nav-link active" id="pay-tab" data-toggle="tab" href="#pay" role="tab" aria-controls="pay" aria-selected="false">充值</a>
						</li>
					 	<li class="nav-item">
					   		<a class="nav-link" id="home-tab" data-toggle="tab" href="#record" role="tab" aria-controls="record" aria-selected="false">统计</a>
					 	</li>
						<li class="nav-item">
							<a class="nav-link" id="profile-tab" data-toggle="tab" href="#donate" role="tab" aria-controls="donate" aria-selected="false">捐助</a>
						</li>
						<li class="nav-item">
							<a class="nav-link" id="hongbao-tab" data-toggle="tab" href="#hongbao" role="tab" aria-controls="hongbao" aria-selected="false">天天领红包</a>
						</li>
					</ul>
					<div class="tab-content" id="myTabContent">
						<div class="tab-pane fade " id="record" role="tabpanel" aria-labelledby="home-tab">
							<table class="table">
							    <thead>
							    <tr>
							        <th>条目</th>
							        <th>数据</th>
							        <th>单位</th>
							    </tr>
							    </thead>
							    <tbody>
							    <tr>
							        <td>今日领取次数</td>
							        <td id="todayGetRecordNumber">0 </td>
							        <td>次 </td>
							    </tr>
							    <tr>
							        <td>今日领取金额</td>
							        <td id="todayGetRecordMoney">0</td>
							        <td>元</td>
							    </tr>
							    <tr>
							        <td>总领取次数</td>
							        <td id="allGetRecordNumber">0</td>
							        <td>次</td>
							    </tr>
							    <tr>
							        <td>总领取金额</td>
							        <td id="allGetRecordMoney">0</td>
							        <td>元</td>
							    </tr>
							    </tbody>
							</table>
						</div>
						<div class="tab-pane fade" id="donate" role="tabpanel" aria-labelledby="profile-tab">
							<div style="padding:1rem;">
								<a>注①：只显示最近5条记录</a>
								<br>
								<a>注②：该列表并不是实时更新的</a>
								<br>
								<a>附：</a><a href="https://github.com/SzPluto/donate" target="view_window">捐助地址</a>
							</div>
							<table class="table">
							    <thead>
							    <tr>
							    	<th>日期</th>
							        <th>昵称</th>
							        <th>金额</th>
							        <th>渠道</th>
							    </tr>
							    </thead>
							    <tbody>
							    <tr>
							        <td id="time0">13/32</td>
							        <td id="name0">不愿透露颜色的黑衣大佬1号 </td>
							        <td id="money0">998 </td>
							        <td id="source0">现金 </td>
							    </tr>
							    <tr>
							        <td id="time1">13/32</td>
							        <td id="name1">不愿透露颜色的黑衣大佬2号 </td>
							        <td id="money1">0.01</td>
							        <td id="source1">银行打款</td>
							    </tr>
							    <tr>
							        <td id="time2">13/32</td>
							        <td id="name2">不愿透露颜色的黑衣大佬3号 </td>
							        <td id="money2">6688</td>
							        <td id="source2">支票</td>
							    </tr>
							    <tr>
							        <td id="time3">13/32</td>
							        <td id="name3">不愿透露颜色的黑衣大佬4号 </td>
							        <td id="money3">8888</td>
							        <td id="source3">空投</td>
							    </tr>
							      <tr>
							        <td id="time4">13/32</td>
							        <td id="name4">不愿透露颜色的黑衣大佬5号 </td>
							        <td id="money4">-10000</td>
							        <td id="source4">打劫</td>
							    </tr>
							    </tbody>
							</table>
						</div>
						<div class="tab-pane fade show active" id="pay" role="tabpanel" aria-labelledby="pay-tab" style="padding-top:1rem;"  align="center">
							<form>
								<div class="input-group mb-3" >
					 				<div class="input-group-prepend" >
					    				<span class="input-group-text" id="basic-addon1">&nbsp;&nbsp;手机&nbsp;&nbsp;</span>
					  				</div>
										<input oninput="checkPayPhone()" class="form-control" type="text" placeholder="请输入要充值的手机号" id="payPhone">
								</div>
								<div class="input-group mb-3" >
					 				<div class="input-group-prepend" >
					    				<span class="input-group-text" id="basic-addon1">目前比例：20点数/元</span>
					  				</div>
									<select class="form-control" id="priceOption">
										<option value="1">1元</option>
										<option value="5">5元</option>
										<option value="10">10元</option>
									</select>
								</div>				                
						       	<div class="radio" align="left">
						            <label>            
						                <p><input type="radio" name="demo1" id="demo1-alipay" value="option1" checked=""> 支付宝支付
						                <input type="radio" name="demo1" id="demo1-weixin" value="option2">微信支付</p>
						            </label>
						            <div class="btn-group btn-group-toggle float-right" data-toggle="buttons">
							            <button disabled="true" type="button" id="demoBtn2" class="btn btn-secondary " onclick="checkBalance()">余额查询</button> 
							            <button disabled="true" type="button" id="demoBtn1" class="btn btn-danger ">提交订单</button> 
							        </div>
							        <p><hr style="margin:0px 0px 0px 0px;"></p>
						      		<a>充值后请自行查询余额，如果有问题请立刻联系群主</a>
						        </div>
						    </form>
						</div>
						<div class="tab-pane fade" id="hongbao" role="tabpanel" aria-labelledby="contact-tab" style="padding:1rem;"  align="center">
							<img src="images/daydayHongbao.jpg" >
						</div>
					</div>
				</div>		
			</div>
			<!-- 页底   -->
			<div align="center">
				<h6 style="color:#463f39">大型同性交友社区 : <a href="https://github.com/SzPluto/elemeHongbao">点击这里</a></h6>
				<h6 style="color:#463f39">本站仅供学习使用，禁止用作违法用途</h6>
				<a  style="text-decoration:line-through;" href="https://github.com/SzPluto/donate" target="view_window">捐助快要饿死的站长</a>
				<br>
				<script src="https://s13.cnzz.com/z_stat.php?id=1273833799&web_id=1273833799" language="JavaScript"></script>
				<input hidden id="check" value="0"></input>
			</div>
		    <form style='display:none;' id='formpay' name='formpay' method='post' action='https://pay.bbbapi.com/'>
		        <input name='goodsname' id='goodsname' type='text' value='' />
		        <input name='istype' id='istype' type='text' value='' />
		        <input name='key' id='key' type='text' value=''/>
		        <input name='notify_url' id='notify_url' type='text' value=''/>
		        <input name='orderid' id='orderid' type='text' value=''/>
		        <input name='orderuid' id='orderuid' type='text' value=''/>
		        <input name='price' id='price' type='text' value=''/>
		        <input name='return_url' id='return_url' type='text' value=''/>
		        <input name='uid' id='uid' type='text' value=''/>
		        <input type='submit' id='submitdemo1'>
		    </form>
		</div>
		
		
		
   		 <!-- jQuery,Popper JS,Bootstrap JS -->
   		<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
		<script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
		<script type="text/javascript">
			//Popover插件加载
			$(function () { 
				$("[data-toggle='popover']").popover();
				
				//加载广告
				$.ajax({  
		            url:"/getAdvertising",  
		            type:"GET",  
		            dataType:"text",  
		            success:function(response){    	
		            	$("#advertising").html(response);
		            },  
		            error:function() {  
		            	$("#advertising").html("前排广告位出租~~饿了么大红包交流群：599753879");
		            }  
		        });
				
				//加载领取记录
				$(function () { 
					$.ajax({  
			            url:"/getRecord",
			            type:"GET",  
			            dataType: 'text',
			            cache:true,
			            success:function(data){
			            	var record=eval("("+data+")"); 
			            	$("#todayGetRecordNumber").html(record.todayGetRecordNumber);
			            	$("#todayGetRecordMoney").html(record.todayGetRecordMoney);
			            	$("#allGetRecordNumber").html(record.allGetRecordNumber);
			            	$("#allGetRecordMoney").html(record.allGetRecordMoney);
			            },
			            error:function() {
			            	$("#todayGetRecordNumber").html(error);
			            	$("#todayGetRecordMoney").html(error);
			            	$("#allGetRecordNumber").html(error);
			            	$("#allGetRecordMoney").html(error);
			            }
			        });
				});
				
				//加载捐献记录
				$(function () { 
					$.ajax({  
			            url:"/getDonate",
			            type:"GET",  
			            dataType: 'text',
			            cache:true,
			            success:function(data){
			            	var donate=eval("("+data+")"); 
			            	for(var i=0;i<5;i++)
			            	{
			            		$("#time"+i).html(donate[i].time);
			            		if(donate[i].name == null){
			            			$("#name"+i).html("不愿透露姓名的大佬");
			            		}else{
			            			$("#name"+i).html(donate[i].name);
			            		}
			            		$("#money"+i).html(donate[i].money);
			            		$("#source"+i).html(donate[i].source);
			            	}
			            	//alert(donate[0].time);
			            	//$("#allGetRecordMoney").html(record.allGetRecordMoney);
			            },
			            error:function() {
			            	$("#todayGetRecordNumber").html(error);
			            	$("#todayGetRecordMoney").html(error);
			            	$("#allGetRecordNumber").html(error);
			            	$("#allGetRecordMoney").html(error);
			            }
			        });
				});
			});
			
			$('#myTab a').on('click', function (e) {
				  e.preventDefault()
				  $(this).tab('show')
				})
			

			
			//ajax提交表单
			function getHongbao(){
				if(checkForm() && document.getElementById("check").value == "0"){		//通过检测value的办法防止重复点击
					document.getElementById("check").value = "1";
					var form = new FormData(document.getElementById("formHongbao"));
		            var xmlHttp = new XMLHttpRequest();
		           xmlHttp.open("post", "/getHongbao", false);
		           xmlHttp.onreadystatechange=function(){
						if(xmlHttp.readyState==4 && xmlHttp.status==200){
			            	alert(xmlHttp.responseText+"\n\n请注意：本站不保证领取到大红包\n具体金额请以实际到账金额为准");
			            }
		            }
		            xmlHttp.send(form);
		            document.getElementById("check").value = "0";
		            document.getElementById("url").value = "";		//领取完后自动清空URL中的内容，防止误触
				}
		    }
			
			//将短链接转换为长链接
			function getLongUrl(){
				$(function () { 
					var shortUrl = $("#url").val();
					$.ajax({  
			            url:"http://api.weibo.com/2/short_url/shorten.json?source=2849184197&url_long="+shortUrl,  
			            type:"GET",  
			            dataType: 'jsonp',
			            cache:true,
			            crossDomain: true,
			            success:function(data){
			            	if(data.data.urls[0].url_long == "https://url.cn/sorry"){
			            		$("#url").val("");
			            		alert("错误的短连接");
			            	}
			            	else{
			            		$("#url").val(data.data.urls[0].url_long); //处理返回数据，显示到网页上 
			            		checkForm();
			            	}
			            },
			            error:function() {
			            	alert("错误的短链接");
			            }
			        });
				});
			}
			
			//查询余额
			function checkBalance(){
				$(function () { 
					$.ajax({  
			            url:"/checkBalance",  
			            type:"Post",  
			            data:"phone="+payPhone.value,
			            dataType: 'text',
			            cache:true,
			            success:function(data){
			            	alert("剩余点数为："+data);
			            },
			            error:function() {
			            	alert("后台未查询到此账号记录");
			            }
			        });
				});
			}
			
			//付款页面
			$().ready(function(){
			    function getistype(){
			        return ($("#demo1-alipay").is(':checked') ? "1" : "2" ); 
			    }
			    $("#demoBtn1").click(function(){
			    	$(function () { 
			    		var options=$("#priceOption option:selected"); //获取选中的项
						$.ajax({  
				            url:"/pay",  
				            type:"POST",  
				            data:"price="+options.val()+"&istype="+getistype()+"&orderuid="+payPhone.value,
				            dataType:"json",
				            cache:true,
				            crossDomain: true,
				            success:function(data){
				            	$("#goodsname").val(data.data.goodsname);
				                $("#istype").val(data.data.istype);
				                $('#key').val(data.data.key);
				                $('#notify_url').val(data.data.notify_url);
				                $('#orderid').val(data.data.orderid);
				                $('#orderuid').val(data.data.orderuid);
				                $('#price').val(data.data.price);
				                $('#return_url').val(data.data.return_url);
				                $('#uid').val(data.data.uid);
				                $('#submitdemo1').click();
				            },
				            error:function() {
				            	alert("错误");
				            }
				        });
					});
			    });
			});
			
			//跳转贡献小号页面
			function submitAlt(){
				if(document.getElementById("phone").value != "" || document.getElementById("url").value != ""){
					var r = confirm("是否回到主页\n请确保Cookie已提交或保存")
					if(r==true){
						window.location.href='/alt';
					}
				}else{
					window.location.href='/alt';
				}
			}
			
			//判断手机号格式
			function checkPhone(){
				var v = document.getElementById("phone").value;
				if(!isNaN(v) && v.length == 11 && v[0]==1){	//如果是数字并且长度等于11并且第一个数字为1
					normalColor("phone");
					return true;
				}else if(v == ""){
					normalColor("phone");
					return false;
				}else{
					warningColor("phone");
					return false;
				}	
			}
			
			//判断支付手机号格式
			function checkPayPhone(){
				var v = document.getElementById("payPhone").value;
				if(!isNaN(v) && v.length == 11 && v[0]==1){	//如果是数字并且长度等于11并且第一个数字为1
					normalColor("payPhone");
					document.getElementById("demoBtn1").disabled=false; 
					document.getElementById("demoBtn2").disabled=false; 
				}else if(v == ""){
					normalColor("payPhone");
					document.getElementById("demoBtn1").disabled=true; 
					document.getElementById("demoBtn2").disabled=true; 
				}else{
					warningColor("payPhone");
					document.getElementById("demoBtn1").disabled=true; 
					document.getElementById("demoBtn2").disabled=true; 
				}	
			}
			
			//判断url格式
			function checkUrl(){
				var v = document.getElementById("url").value;
				var reg1 = /lucky_number/;
				var reg2 = /https:\/\/h5.ele.me\/hongbao\//;
				if((reg1.test(v) && reg2.test(v))){
					normalColor("url");
					return true;
				}else if(v == ""){
					normalColor("url");
					return false;
				}else{
					warningColor("url");
					return false;
				}
			}
			
			//检测并转换短连接
			function urlExpand(){
				var url = document.getElementById("url").value;
				var reg = /url.cn/;
				if(reg.test(url)){
					normalColor("url");
					getLongUrl();
				}
			}
			//格式错误显示颜色
			function warningColor(id){
				document.getElementById(id).style.backgroundColor = "#dd3444";
				document.getElementById(id).style.color = "white";
			}
			
			//格式正确显示颜色
			function normalColor(id){
				document.getElementById(id).style.backgroundColor = "white";
				document.getElementById(id).style.color = "#6c757d";
			}
			
			//表单检测
			function checkForm(){
				var urltip = checkUrl();
				var phonetip = checkPhone();
				if (urltip && phonetip){
					document.getElementById("get").disabled=false; 
					return true;
				}else{
					document.getElementById("get").disabled=true; 
					return false;
				}
			}
		</script>
	</body>
</html>